package com.capt_4;

import com.capt_4.equation.AddEquation;
import com.capt_4.equation.Equation;
import com.capt_4.equation.SubEquation;
import com.capt_4.io.EquationDao;

import javax.swing.*;
import java.awt.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {

//       习题集写入
        Exercise ex = new Exercise();
//        // 设置习题集数目
        ex.setExerciseNumber(50);
//        // 生成习题集
        // 混合题集合
//        ex.generateRandomExercise();
        // 加法
//        ex.generateAddExercise();
        // 减法
        ex.generateSubExercise();


//        ex.printExercise();



        EquationDao equationDao = new EquationDao();
        // 加法
//        equationDao.writExerciseToFile(ex,"/home/gonglidong/Desktop/linuxText/Maven/SpringBootMaven/CXSJ_Student/src/com/capt_4/io/add.txt");
        // 减法
        equationDao.writExerciseToFile(ex,"/home/gonglidong/Desktop/linuxText/Maven/SpringBootMaven/CXSJ_Student/src/com/capt_4/io/sub.txt");
        // 混合习题
//        equationDao.writExerciseToFile(ex,"/home/gonglidong/Desktop/linuxText/Maven/SpringBootMaven/CXSJ_Student/src/com/capt_4/io/text.txt");

        // 习题集读取
//        EquationDao equationDao = new EquationDao();
        // 加法
//        Exercise exercise = equationDao.readExerciseFromFile("/home/gonglidong/Desktop/linuxText/Maven/SpringBootMaven/CXSJ_Student/src/com/capt_4/io/add.txt");
        // 减法
        Exercise exercise = equationDao.readExerciseFromFile("/home/gonglidong/Desktop/linuxText/Maven/SpringBootMaven/CXSJ_Student/src/com/capt_4/io/sub.txt");
        // 混合习题
//        Exercise exercise = equationDao.readExerciseFromFile("/home/gonglidong/Desktop/linuxText/Maven/SpringBootMaven/CXSJ_Student/src/com/capt_4/io/text.txt");

//        System.out.println("读取题目集打印:");
//        for (int i = 0; i < 50; i++) {
//            System.out.println(exercise.getList().get(i));
//        }

        //   批改
        Answer answer = new Answer();
        Check check = new Check();

        System.out.println("请输入答案:");
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < 3; i++) {
            int a = scanner.nextInt();
            answer.add(a);
        }
        check.checkExercise(answer,ex);
        check.printCheck();

    }
}
